package widok;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Szablon extends widok.Widok {

	private String jsp;
	private model.Bean bean;

	public Szablon(String jsp, model.Bean bean) {
		this.jsp = jsp;
		this.bean = bean;
	}

	@Override
	public void pokaz(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws IOException, ServletException {
		RequestDispatcher disp;
		disp = context.getRequestDispatcher("/template/encje/szablon.jsp");

		request.setAttribute("bean", bean);
		request.setAttribute("szablon", jsp);
		request.setAttribute("uzytkownik", (String)request.getSession().getAttribute("uzytkownik"));
		
		// synchronize the Application so the JSP file
		// doesn't need to worry about threading
		synchronized (context) {
			disp.forward(request, response);
		}

	}

}
